package com.ask.forMe.controller.business;

import com.ask.forMe.model.entity.Order;
import com.ask.forMe.model.entity.Result;
import com.ask.forMe.service.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@Tag(name = "订单接口")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/orderNum")
    @Operation(summary = "根据订单号查询")
    public Result getByOrderNum(String orderNum) {
        Order order = orderService.queryByOrderNum(orderNum);
        return order == null ? Result.fail("订单不存在！") : Result.success(order);
    }
}
